home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tpack / userbde.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  4.3 KB  |  130 lines

  1. unit UserBDE;
  2.  
  3. {A UserInfo component for BDE users. Need I say more? sure, but I rather you read it.}
  4.  
  5. {CAVEAT: made to work for production, not peer-reviewed. that's what you are doing now!}
  6.  
  7. {-----------------------------------------------------------------------------------------}
  8. { USERBDE                                                                                 }
  9. {-----------------------------------------------------------------------------------------}
  10.  
  11. interface
  12.  
  13. uses
  14.   Classes
  15.   ,dbiTypes
  16.   ,UserInfo;
  17.  
  18. Type
  19.   TBDEUserInfo = class(TUserInfo)
  20.   {this wrapper for a couple of bde status calls demonstrates initializing vis UpdateOK}
  21.   private
  22.     fLocalShare     : Boolean;       { If Local files will be shared }
  23.     fNetProtocol    : Word;          { Net Protocol (35, 40 etc.) }
  24.     fNetShare       : Boolean;       { True if connected to network }
  25.     fzNetType       : DBINAME;       { Network type }
  26.     fzUserName      : DBIUSERNAME;   { Network user name }
  27.     fzIniFile       : DBIPATH;       { Configuration file }
  28.     fzLangDriver    : DBINAME;       { System language driver }
  29.   protected
  30.     function GetPath:String;
  31.     function GetDriver:String;
  32.     function GetNetType:String;
  33.     function GetUserName:String;
  34.     procedure SetNoWord(Value:Word);
  35.     procedure SetNoBool(Value:Boolean);
  36.     procedure SetNoString(const Value:String);
  37.   public
  38.     Constructor Create(aOwner:TComponent); Override;
  39.     function UpdateOK:boolean; Override;
  40.   published
  41.     property NetProtocol   : Word read fNetProtocol write SetNoWord;   { Net Protocol (35, 40 etc.) }
  42.     property LocalShare    : Boolean read fLocalShare write SetNoBool; { If Local files will be shared }
  43.     property NetShare      : Boolean read fNetShare write SetNoBool;   { True if connected to network }
  44.     property NetType       : String read GetNetType write SetNoString; { Network type }
  45.     property UserName      : String read GetUserName write SetNoString;{ Network user name }
  46.     property IniFile       : String read GetPath write SetNoString;    { Configuration file }
  47.     property LangDriver    : String read GetDriver write SetNoString;  { System language driver }
  48.     end;
  49.  
  50. implementation
  51.  
  52. uses
  53.   dbiProcs, sysUtils;
  54.  
  55. {-----------------------------------------------------------------------------------------}
  56. { OBJECT CREATION                                                                         }
  57. {-----------------------------------------------------------------------------------------}
  58.  
  59. Constructor TBDEUserInfo.Create(aOwner:TComponent);
  60. begin
  61.   inherited Create(aOwner);
  62.   fzNetType[0]    := #0;
  63.   fzUserName[0]   := #0;
  64.   fzIniFile[0]    := #0;
  65.   fzLangDriver[0] := #0;
  66. end;
  67.  
  68. function TBDEUserInfo.UpdateOK:boolean;
  69. var
  70.   BDEcfg: SYSConfig;      { BDE Configuration information record }
  71. begin
  72.   Result:=inherited UpdateOK;
  73.   if not Result then
  74.     Exit;
  75.   DbiGetSysConfig(BDEcfg);
  76.   with BDEcfg do begin
  77.     fNetProtocol    := iNetProtocol;
  78.     fLocalShare     := bLocalShare;
  79.     fNetShare       := bNetShare;
  80.     fzNetType       := fzNetType;
  81.     fzUserName      := szUserName;
  82.     fzIniFile       := fzIniFile;
  83.     fzLangDriver    := fzLangDriver;
  84.     end;
  85. end;
  86.  
  87. {-----------------------------------------------------------------------------------------}
  88. { OBJECT PLUMBING  (convert PChar to Pascal String)                                       }
  89. {-----------------------------------------------------------------------------------------}
  90.  
  91. function TBDEUserInfo.GetPath:String;
  92. begin
  93.   Result:=StrPas(fzIniFile);
  94. end;
  95.  
  96. function TBDEUserInfo.GetDriver:String;
  97. begin
  98.   Result:=StrPas(fzLangDriver);
  99. end;
  100.  
  101. function TBDEUserInfo.GetNetType:String;
  102. begin
  103.   Result:=StrPas(fzNetType);
  104. end;
  105.  
  106. function TBDEUserInfo.GetUserName:String;
  107. begin
  108.   Result:=StrPas(fzUserName);
  109. end;
  110.  
  111. {}
  112.  
  113. procedure TBDEUserInfo.SetNoWord(Value:Word);
  114. begin
  115. end;
  116.  
  117. procedure TBDEUserInfo.SetNoBool(Value:Boolean);
  118. begin
  119. end;
  120.  
  121. procedure TBDEUserInfo.SetNoString(const Value:String);
  122. begin
  123. end;
  124.  
  125. {-----------------------------------------------------------------------------------------}
  126. {                                                                                         }
  127. {-----------------------------------------------------------------------------------------}
  128.  
  129. end.
  130.